#include<cstdio>
#include<algorithm>
#include<vector>
#define openfile(s) freopen(s".in","r",stdin);freopen(s".out","w",stdout)
using namespace std;
const int N=2e3+1;
const long long MOD=998244353,MODP=998244352;
long long mod(long long a,long long b=MOD)
{
	a-=a/b*b;
	return a<0?a+b:a;
}
long long pow(long long a,long long b)
{
	long long ret=1;
	a=mod(a);
	b=mod(b,MODP);
	for(;b;b>>=1){
		if(b&1) ret=ret*a%MOD;
		a=a*a%MOD;
	}
	return ret;
}
vector<int> pri;
vector<int> divide(long long x)
{
	vector<int> ret;
	ret.reserve(pri.size());
	for(int p:pri){
		int c=0;
		for(;x%p==0;x/=p,c++);
		ret.push_back(c);
	}
	return ret;
}
vector<long long> getDivider(long long x)
{
	vector<long long> ret;
	vector<int> times=divide(x);
	auto dfs=[&](auto& func,int now,long long num){
		if(now>=pri.size()){
			ret.push_back(num);
			return;
		}
		for(int i=0;i<=times[now];i++,num*=pri[now])
			func(func,now+1,num);
		return;
	};
	dfs(dfs,0,1);
	return ret;
}
long long phi(long long x)
{
	long long ret=x;
	for(int p:pri)
		if(x%p==0)
			ret=ret/p*(p-1);
	return ret;
}
void work()
{
	int m;
	long long n=1,a,b;
	scanf("%d",&m);
	for(;m;m--){
		int x;
		scanf("%d",&x);
		n*=x;
		pri.push_back(x);
	}
	scanf("%lld%lld",&a,&b);
	if(n==3){
		printf("%lld",mod(pow(a,n)*pow(b,n*(n-1)/2)-3*a*a%MOD*b%MOD*b%MOD+2*a*b));
		return;
	}
	sort(pri.begin(),pri.end());
	pri.erase(unique(pri.begin(),pri.end()),pri.end());
	long long ans=0;
	if(n&1) ans=n%MOD*pow(a,(n+1)/2)%MOD*pow(b,((__int128)n*n-1)/4%MODP)%MOD;
	else ans=n/2%MOD*pow(a,n/2)%MOD*pow(b,(__int128)n*n/4%MODP)%MOD*(a+1)%MOD;
	for(long long d:getDivider(n))
		ans=(ans+phi(n/d)%MOD*pow(a,d)%MOD*pow(b,d%MODP*(n-d+d/2)))%MOD;
	ans=ans*pow(2*n,MOD-2)%MOD;
	printf("%lld",ans);
	return;
}
int main()
{
	freopen("input.in","r",stdin);
//	freopen("output.out","w",stdout);
	openfile("clown");
	work();
	return 0;
}
